package com.cloudpan.common.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * @Author sc
 * @DATE 2024/1/18 18:12
 * @Description:
 * @Version 1.0
 */
@Configuration
public class SwaggerConfig {

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .pathMapping("/")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.cloudpan.controller"))
                .paths(PathSelectors.any())
                .build()
                .apiInfo(apiInfo());
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                //标题
                .title("基于Minio对象存储的网盘系统-API接口文档")
                //描述
                .description("基于Minio对象存储的网盘系统")
                //服务的团队
                .termsOfServiceUrl("原野")
                //作者的信息
                .contact(new Contact("原野", "4399.com", "yuanye6059@outlook.com"))
                //授权信息
                .license("The Apache License")
                //授权的url
                .licenseUrl("http://localhost:7090/swagger-ui.html#/")
                //版本号
                .version("1.0.0")
                .build();
    }
}
